package com.koron.order.LineHomepage.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.bean.system.staff.vo.EamUser;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.LineHomepage.bean.VO.LineTripVO;
import com.koron.order.LineHomepage.bean.query.LineTripQuery;
import com.koron.order.LineHomepage.service.LineTripVOService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: LineTripController
 * @Description:
 * @Date: 2023/2/18
 * @Author: 李一辰
 * @Version: 1.0
 **/
@Slf4j
@Api(tags = "线路跳闸记录")
@RestController
@RequestMapping("/lineTripController")
public class LineTripController {
    @Autowired
    private LineTripVOService lineTripVOService;


    private EamUser getCurr() {
        return ThreadLocalContext.get();
    }

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation("分页")
    @GetMapping("/page")
    public Response<PageInfo<LineTripVO>> page(LineTripQuery lineTripQuery, PageQuery pageQuery) {
        PageInfo<LineTripVO> page = ADOConnection.runTask(getCurrDs(), lineTripVOService, "page", PageInfo.class, lineTripQuery, pageQuery);
        return Response.ok(page);
    }
    @ApiOperation("根据id进行查询")
    @GetMapping("/getById")
    public Response<LineTripVO> getById(@RequestParam("id") String id) {
        LineTripVO lineTripVO = ADOConnection.runTask(getCurrDs(), lineTripVOService, "getById", LineTripVO.class, id);
       return  Response.ok(lineTripVO);
    }


    @ApiOperation("新增")
    @PostMapping("/insert")
    public Response<LineTripVO> insert(@RequestBody LineTripVO lineTripVO) {
        LineTripVO lineTrip = ADOConnection.runTask(getCurrDs(), lineTripVOService, "save", LineTripVO.class, lineTripVO);
        return Response.ok(lineTrip);
    }

    @ApiOperation("逻辑删除")
    @GetMapping("/hidden")
    public Response<Boolean> deleteLogic(String id){
        Boolean deleteLogic = ADOConnection.runTask(getCurrDs(), lineTripVOService, "deleteLogic", Boolean.class, id);
        return Response.ok(deleteLogic);
    }



}
